<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>IfInString / IfNotInString</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="../css/default.css" rel="stylesheet" type="text/css">
</head>
<body>

<h1>IfInString / IfNotInString</h1>

<p>检查 <a href="../Variables.htm">变量</a> 是否包含指定的字符串.</p>

<pre class="Syntax">IfInString, var, SearchString
IfNotInString, var, SearchString
Position := <a href="../Functions.htm#InStr">InStr</a>(Haystack, Needle [, CaseSensitive?, StartingPos]]) <em>; 参见 <a href="../Functions.htm#InStr">InStr() 函数</a> 了解详细信息.</em></pre>
<h3>参数</h3>
<table class="info">
  <tr> 
    <td width="15%">var</td>
    <td width="85%">为寻找匹配而被搜索的 <a href="../Variables.htm">变量</a> 名称.</td>
  </tr>
  <tr>
    <td>SearchString</td>
    <td>要搜索的字符串. 如果没有启用 <a href="StringCaseSense.htm">StringCaseSense</a>, 那么匹配过程不区分大小写.</td>
  </tr>
</table>

<h3>备注</h3>
<p>内置变量 <a href="../Variables.htm">%A_Space%</a> 和 <a href="../Variables.htm">%A_Tab%</a> 分别包含单个空格和单个 tab 字符, 单独搜索这些字符时它们可能很有用.</p>
<p>另一个命令可以和此命令在同一行. 换句话说, 这两个语句是等同的:</p>
<pre>IfInString, MyVar, abc, Gosub, Process1
IfInString, MyVar, abc
    Gosub, Process1</pre>
<p>不过, 除命名命令外的其他项不支持与此命令在相同行. 例如:</p>
<pre>IfInString, MyVar, abc, found := true  <em><strong>; 无效的.</strong></em></pre>
<h3>相关</h3>
<p><a href="../Functions.htm#InStr">InStr()</a>, <a href="RegExMatch.htm">RegExMatch()</a>, <a href="StringGetPos.htm">StringGetPos</a>, <a href="StringCaseSense.htm">StringCaseSense</a>, <a href="IfEqual.htm">IfEqual</a>, <a href="IfIn.htm">if var in/contains MatchList</a>, <a href="IfBetween.htm">if var between</a>, <a href="IfIs.htm">if var is type</a>, <a href="Block.htm">区块</a>, <a href="Else.htm">Else</a></p>
<h3>示例</h3>
<pre class="NoIndent">Haystack = abcdefghijklmnopqrs
Needle = abc
IfInString, Haystack, %Needle%
{
    MsgBox, The string was found.
    return
}
else
    Sleep, 1</pre>

</body>
</html>
